package com.sxt.util;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class ActionMapping {
	private String actionName;
	private String actionClassName;
	private String methodName;
	public String getMethodName() {
		return methodName;
	}

	public void setMethodName(String methodName) {
		this.methodName = methodName;
	}

	private Map<String, String> result;

	public ActionMapping() {
		super();
	}

	public ActionMapping(String actionName, String actionClassName,
			Map<String, String> result) {
		super();
		this.actionName = actionName;
		this.actionClassName = actionClassName;
		this.result = result;
	}

	public String getActionName() {
		return actionName;
	}

	public void setActionName(String actionName) {
		this.actionName = actionName;
	}

	public String getActionClassName() {
		return actionClassName;
	}

	public void setActionClassName(String actionClassName) {
		this.actionClassName = actionClassName;
	}

	public Map<String, String> getResult() {
		return result;
	}

	public void setResult(Map<String, String> result) {
		this.result = result;
	}
	
	public static void main(String[] args) {
		ActionMapping loginMapping = new ActionMapping();
		loginMapping.setActionName("login");
		loginMapping.setActionClassName("com.sxt.model.LoginAction");
		loginMapping.setMethodName("login");
		Map<String, String> results = new HashMap<String, String>();
		results.put("sucess", "list.html");
		results.put("failed", "error.html");
		results.put("unknow", "error.html");
		loginMapping.setResult(results);
		
		//储存多个action配置项目
		Map<String, ActionMapping> actionsConfig = new HashMap<String, ActionMapping>();
		actionsConfig.put("login", loginMapping);
		
		//查询数据
		String actionName = "login";
		ActionMapping targetActionMapping = actionsConfig.get(actionName);
		System.out.println("actionName-->" + targetActionMapping.getActionName());
		System.out.println("actionClass-->" + targetActionMapping.getActionClassName());
		System.out.println("methodName-->" + targetActionMapping.getMethodName());
		
		Map<String, String> actionResults = targetActionMapping.getResult();
		Iterator<String> it = actionResults.keySet().iterator();
		while (it.hasNext()) {
			String key = it.next();
			System.out.println("key-->" + key + ",value-->" + actionResults.get(key));
		}
	}
}
